define(['egis'], function (egis) {
    Window.deserializer = Window.deserializer || new egis.core.Deserializer();
    Window.container = Window.container || {};
    dsBridge.register('create_RestWFSService', function (sourceId, url, http, authType, clientId, clientSecret, tokenUrl) {
        var restHttp = Window.container[http];
        var restGeoService = new egis.ews.RestWFSService({
            url: url,
            http: restHttp,
            deserializer: Window.deserializer,
            authType: authType,
            clientId: clientId,
            clientSecret: clientSecret,
            tokenUrl: tokenUrl
        });
        Window.container[sourceId] = restGeoService;
    });

    dsBridge.registerAsyn('RestWFSService_getCapabilities', function (sourceId, capabilitiesInput, responseCallback) {
        var restWFSService = Window.container[sourceId];
        capabilitiesInput = Window.deserializer.createJsInstance(JSON.parse(capabilitiesInput));
        restWFSService.getCapabilities(capabilitiesInput).then(function (value) {
            responseCallback(value);
        })
    })

    dsBridge.registerAsyn('RestWFSService_getDescripbeFeatureType', function (sourceId, featureTypeInput, responseCallback) {
        var restWFSService = Window.container[sourceId];
        featureTypeInput = Window.deserializer.createJsInstance(JSON.parse(featureTypeInput));
        restWFSService.getDescripbeFeatureType(featureTypeInput).then(function (value) {
            responseCallback(value);
        })
    })
    dsBridge.registerAsyn('RestWFSService_getFeature', function (sourceId, featureInput, responseCallback) {
        var restWFSService = Window.container[sourceId];
        console.log("resetwfsservice============"+restWFSService)
        console.log("inputjson============"+JSON.stringify(featureInput))
        featureInput = Window.deserializer.createJsInstance(JSON.parse(featureInput));
        console.log("featureInput============="+featureInput)
        restWFSService.getFeature(featureInput).then(function (value) {
            console.log("value============"+value)
            responseCallback(JSON.stringify(value));
        })
    })
})